Skip to main content

Run API tests from a workflow

Run a published collection as a step of a workflow, then act on the result, for example to stop or branch when a test fails.

info

Before you start.

  • A published collection that runs successfully on its own (Running tests). A draft cannot be used by a workflow.
  • Access to the Workflow Builder.
  • An environment for the collection.
  • The person who starts the workflow needs the permissions the node uses, for example View Environment and Run Test (Permissions).

Steps​

  1. Create or open a workflow. In Workflow Builder, create a new workflow or edit an existing one. Every workflow starts with a Start node.

  2. Add the API Test node. Click the plus icon below the Start node and add Run API test collection. To run only one case, add Run API test case instead.

  3. Set the node's parameters. Select the node and open Parameters:

    ParameterWhat to choose
    API Test CollectionA published collection.
    VersionA pinned version (v<n> (pinned)) so that publishing a new version does not change what the workflow runs. Always latest published is also offered, with a warning.
    EnvironmentAn environment the collection already defines.
    Repeat the collectionOptional, 1 to 20 passes.

    See API Test node in Workflows.

  4. Decide what happens after a failure. Failed test cases do not fail the workflow step. To act on the result, add a Condition node after the API Test node and test one of its outputs, for example failed, using @{{context.NODE_ID.failed}}. The node's panel shows the exact prefix to use under "Published into run context". See Outputs you can use in later nodes.

  5. Save and publish the workflow. Click Save, then Publish. You can use Test Run and Semantic Check first.

  6. Run the workflow and read the results. Start the workflow. Open the workflow's Run History tab, find the run and click View results in the API Tests column.

Check the result​

Run results shows Passed, Failed, Blocked, Skipped and the pass rate summed over every API Test node, and one row per node. Open the full report to see the assertion detail. The run also appears in the collection's own History with the trigger WORKFLOW.

Common problems​

What you seeWhyWhat to do
Node shows Could not run with VALIDATION_FAILED and a permission messageThe person who started the workflow lacks a permission, for example View EnvironmentAsk your administrator for the permission.
The collection is not in the listIt is not publishedPublish it first.
Not reachedAn earlier node stopped the workflowCheck the nodes before it.
Results change after you publish a new versionThe node uses Always latest publishedPin a version.